﻿
Ext.define('YZSoft.src.panel.VideoPlayer', {
    extend: 'Ext.Panel',
    fullscreen: true,
    config: {
        fileid: null
    },
    items: [{
        xtype: 'video',
        x: 600,
        y: 300,
        width: 175,
        height: 98,
        url: "porsche911.mov",
        posterUrl: 'porsche.png'
    }],

    constructor: function (config) {
        var me = this,
            fileid = config.fileid,
            cfg, videoUrl, imageUrl;

        videoUrl = Ext.String.urlAppend(YZSoft.$url('YZSoft.Services/Attachment/Download.ashx'), Ext.Object.toQueryString({
            Method: 'VideoStreamFromFileID',
            fileid: fileid,
            dc: +new Date()
        }));

        imageUrl = Ext.String.urlAppend(YZSoft.$url('YZSoft.Services/Attachment/Download.ashx'), Ext.Object.toQueryString({
            Method: 'ImageStreamFromFileID',
            fileid: fileid,
            dc: +new Date()
        }));

        me.video = Ext.create('Ext.Video', {
            url: videoUrl,
            posterUrl: imageUrl,
            autoResume:true
        });

        //        me.video = Ext.create('YZSoft.src.component.jPlayer', {
        //            region: 'north',
        //            cls: 'yz-jplayer-onsite',
        //            listeners: {
        //                ready: function () {
        //                    me.video.setMedia({
        //                        title: 'Bubble',
        //                        mp4: videoUrl
        //                    });
        //                }
        //            }
        //        });

        cfg = {
            items: [me.video]
        };

        Ext.apply(cfg, config);
        me.callParent([cfg]);

        me.video.play();
    }
});